<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - Lua 5.2.4 - src/ldebug.c</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">src</a> - ldebug.c</td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">Lua 5.2.4</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">282</td>
            <td class="headerCovTableEntry">341</td>
            <td class="headerCovTableEntryMed">82.7 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2019-06-13 19:44:16</td>
            <td></td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<span class="lineNum">       1 </span>            : /*
<span class="lineNum">       2 </span>            : ** $Id: ldebug.c,v 2.90.1.4 2015/02/19 17:05:13 roberto Exp $
<span class="lineNum">       3 </span>            : ** Debug Interface
<span class="lineNum">       4 </span>            : ** See Copyright Notice in lua.h
<span class="lineNum">       5 </span>            : */
<span class="lineNum">       6 </span>            : 
<span class="lineNum">       7 </span>            : 
<span class="lineNum">       8 </span>            : #include &lt;stdarg.h&gt;
<span class="lineNum">       9 </span>            : #include &lt;stddef.h&gt;
<span class="lineNum">      10 </span>            : #include &lt;string.h&gt;
<span class="lineNum">      11 </span>            : 
<span class="lineNum">      12 </span>            : 
<span class="lineNum">      13 </span>            : #define ldebug_c
<span class="lineNum">      14 </span>            : #define LUA_CORE
<span class="lineNum">      15 </span>            : 
<span class="lineNum">      16 </span>            : #include &quot;lua.h&quot;
<span class="lineNum">      17 </span>            : 
<span class="lineNum">      18 </span>            : #include &quot;lapi.h&quot;
<span class="lineNum">      19 </span>            : #include &quot;lcode.h&quot;
<span class="lineNum">      20 </span>            : #include &quot;ldebug.h&quot;
<span class="lineNum">      21 </span>            : #include &quot;ldo.h&quot;
<span class="lineNum">      22 </span>            : #include &quot;lfunc.h&quot;
<span class="lineNum">      23 </span>            : #include &quot;lobject.h&quot;
<span class="lineNum">      24 </span>            : #include &quot;lopcodes.h&quot;
<span class="lineNum">      25 </span>            : #include &quot;lstate.h&quot;
<span class="lineNum">      26 </span>            : #include &quot;lstring.h&quot;
<span class="lineNum">      27 </span>            : #include &quot;ltable.h&quot;
<span class="lineNum">      28 </span>            : #include &quot;ltm.h&quot;
<span class="lineNum">      29 </span>            : #include &quot;lvm.h&quot;
<span class="lineNum">      30 </span>            : 
<span class="lineNum">      31 </span>            : 
<span class="lineNum">      32 </span>            : 
<span class="lineNum">      33 </span>            : #define noLuaClosure(f)         ((f) == NULL || (f)-&gt;c.tt == LUA_TCCL)
<span class="lineNum">      34 </span>            : 
<span class="lineNum">      35 </span>            : 
<span class="lineNum">      36 </span>            : static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name);
<span class="lineNum">      37 </span>            : 
<span class="lineNum">      38 </span>            : 
<span class="lineNum">      39 </span><span class="lineCov">        404 : static int currentpc (CallInfo *ci) {</span>
<span class="lineNum">      40 </span>            :   lua_assert(isLua(ci));
<span class="lineNum">      41 </span><span class="lineCov">        404 :   return pcRel(ci-&gt;u.l.savedpc, ci_func(ci)-&gt;p);</span>
<span class="lineNum">      42 </span>            : }
<span class="lineNum">      43 </span>            : 
<span class="lineNum">      44 </span>            : 
<span class="lineNum">      45 </span><span class="lineCov">        288 : static int currentline (CallInfo *ci) {</span>
<span class="lineNum">      46 </span><span class="lineCov">        288 :   return getfuncline(ci_func(ci)-&gt;p, currentpc(ci));</span>
<span class="lineNum">      47 </span>            : }
<span class="lineNum">      48 </span>            : 
<span class="lineNum">      49 </span>            : 
<span class="lineNum">      50 </span><span class="lineCov">        462 : static void swapextra (lua_State *L) {</span>
<span class="lineNum">      51 </span><span class="lineCov">        462 :   if (L-&gt;status == LUA_YIELD) {</span>
<span class="lineNum">      52 </span><span class="lineNoCov">          0 :     CallInfo *ci = L-&gt;ci;  /* get function that yielded */</span>
<span class="lineNum">      53 </span><span class="lineNoCov">          0 :     StkId temp = ci-&gt;func;  /* exchange its 'func' and 'extra' values */</span>
<span class="lineNum">      54 </span><span class="lineNoCov">          0 :     ci-&gt;func = restorestack(L, ci-&gt;extra);</span>
<span class="lineNum">      55 </span><span class="lineNoCov">          0 :     ci-&gt;extra = savestack(L, temp);</span>
<span class="lineNum">      56 </span>            :   }
<span class="lineNum">      57 </span><span class="lineCov">        462 : }</span>
<span class="lineNum">      58 </span>            : 
<span class="lineNum">      59 </span>            : 
<span class="lineNum">      60 </span>            : /*
<span class="lineNum">      61 </span>            : ** this function can be called asynchronous (e.g. during a signal)
<span class="lineNum">      62 </span>            : */
<span class="lineNum">      63 </span><span class="lineCov">          2 : LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {</span>
<span class="lineNum">      64 </span><span class="lineCov">          2 :   if (func == NULL || mask == 0) {  /* turn off hooks? */</span>
<span class="lineNum">      65 </span><span class="lineCov">          1 :     mask = 0;</span>
<span class="lineNum">      66 </span><span class="lineCov">          1 :     func = NULL;</span>
<span class="lineNum">      67 </span>            :   }
<span class="lineNum">      68 </span><span class="lineCov">          2 :   if (isLua(L-&gt;ci))</span>
<span class="lineNum">      69 </span><span class="lineNoCov">          0 :     L-&gt;oldpc = L-&gt;ci-&gt;u.l.savedpc;</span>
<span class="lineNum">      70 </span><span class="lineCov">          2 :   L-&gt;hook = func;</span>
<span class="lineNum">      71 </span><span class="lineCov">          2 :   L-&gt;basehookcount = count;</span>
<span class="lineNum">      72 </span><span class="lineCov">          2 :   resethookcount(L);</span>
<span class="lineNum">      73 </span><span class="lineCov">          2 :   L-&gt;hookmask = cast_byte(mask);</span>
<span class="lineNum">      74 </span><span class="lineCov">          2 :   return 1;</span>
<span class="lineNum">      75 </span>            : }
<span class="lineNum">      76 </span>            : 
<span class="lineNum">      77 </span>            : 
<span class="lineNum">      78 </span><span class="lineCov">          3 : LUA_API lua_Hook lua_gethook (lua_State *L) {</span>
<span class="lineNum">      79 </span><span class="lineCov">          3 :   return L-&gt;hook;</span>
<span class="lineNum">      80 </span>            : }
<span class="lineNum">      81 </span>            : 
<span class="lineNum">      82 </span>            : 
<span class="lineNum">      83 </span><span class="lineCov">          3 : LUA_API int lua_gethookmask (lua_State *L) {</span>
<span class="lineNum">      84 </span><span class="lineCov">          3 :   return L-&gt;hookmask;</span>
<span class="lineNum">      85 </span>            : }
<span class="lineNum">      86 </span>            : 
<span class="lineNum">      87 </span>            : 
<span class="lineNum">      88 </span><span class="lineCov">          3 : LUA_API int lua_gethookcount (lua_State *L) {</span>
<span class="lineNum">      89 </span><span class="lineCov">          3 :   return L-&gt;basehookcount;</span>
<span class="lineNum">      90 </span>            : }
<span class="lineNum">      91 </span>            : 
<span class="lineNum">      92 </span>            : 
<span class="lineNum">      93 </span><span class="lineCov">        254 : LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {</span>
<span class="lineNum">      94 </span>            :   int status;
<span class="lineNum">      95 </span>            :   CallInfo *ci;
<span class="lineNum">      96 </span><span class="lineCov">        254 :   if (level &lt; 0) return 0;  /* invalid (negative) level */</span>
<span class="lineNum">      97 </span>            :   lua_lock(L);
<span class="lineNum">      98 </span><span class="lineCov">        531 :   for (ci = L-&gt;ci; level &gt; 0 &amp;&amp; ci != &amp;L-&gt;base_ci; ci = ci-&gt;previous)</span>
<span class="lineNum">      99 </span><span class="lineCov">        277 :     level--;</span>
<span class="lineNum">     100 </span><span class="lineCov">        254 :   if (level == 0 &amp;&amp; ci != &amp;L-&gt;base_ci) {  /* level found? */</span>
<span class="lineNum">     101 </span><span class="lineCov">        233 :     status = 1;</span>
<span class="lineNum">     102 </span><span class="lineCov">        233 :     ar-&gt;i_ci = ci;</span>
<span class="lineNum">     103 </span>            :   }
<span class="lineNum">     104 </span><span class="lineCov">         21 :   else status = 0;  /* no such level */</span>
<span class="lineNum">     105 </span>            :   lua_unlock(L);
<span class="lineNum">     106 </span><span class="lineCov">        254 :   return status;</span>
<span class="lineNum">     107 </span>            : }
<span class="lineNum">     108 </span>            : 
<span class="lineNum">     109 </span>            : 
<span class="lineNum">     110 </span><span class="lineCov">         62 : static const char *upvalname (Proto *p, int uv) {</span>
<span class="lineNum">     111 </span><span class="lineCov">         62 :   TString *s = check_exp(uv &lt; p-&gt;sizeupvalues, p-&gt;upvalues[uv].name);</span>
<span class="lineNum">     112 </span><span class="lineCov">         62 :   if (s == NULL) return &quot;?&quot;;</span>
<span class="lineNum">     113 </span><span class="lineCov">         62 :   else return getstr(s);</span>
<span class="lineNum">     114 </span>            : }
<span class="lineNum">     115 </span>            : 
<span class="lineNum">     116 </span>            : 
<span class="lineNum">     117 </span><span class="lineNoCov">          0 : static const char *findvararg (CallInfo *ci, int n, StkId *pos) {</span>
<span class="lineNum">     118 </span><span class="lineNoCov">          0 :   int nparams = clLvalue(ci-&gt;func)-&gt;p-&gt;numparams;</span>
<span class="lineNum">     119 </span><span class="lineNoCov">          0 :   if (n &gt;= ci-&gt;u.l.base - ci-&gt;func - nparams)</span>
<span class="lineNum">     120 </span><span class="lineNoCov">          0 :     return NULL;  /* no such vararg */</span>
<span class="lineNum">     121 </span>            :   else {
<span class="lineNum">     122 </span><span class="lineNoCov">          0 :     *pos = ci-&gt;func + nparams + n;</span>
<span class="lineNum">     123 </span><span class="lineNoCov">          0 :     return &quot;(*vararg)&quot;;  /* generic name for any vararg */</span>
<span class="lineNum">     124 </span>            :   }
<span class="lineNum">     125 </span>            : }
<span class="lineNum">     126 </span>            : 
<span class="lineNum">     127 </span>            : 
<span class="lineNum">     128 </span><span class="lineCov">          3 : static const char *findlocal (lua_State *L, CallInfo *ci, int n,</span>
<span class="lineNum">     129 </span>            :                               StkId *pos) {
<span class="lineNum">     130 </span><span class="lineCov">          3 :   const char *name = NULL;</span>
<span class="lineNum">     131 </span>            :   StkId base;
<span class="lineNum">     132 </span><span class="lineCov">          3 :   if (isLua(ci)) {</span>
<span class="lineNum">     133 </span><span class="lineNoCov">          0 :     if (n &lt; 0)  /* access to vararg values? */</span>
<span class="lineNum">     134 </span><span class="lineNoCov">          0 :       return findvararg(ci, -n, pos);</span>
<span class="lineNum">     135 </span>            :     else {
<span class="lineNum">     136 </span><span class="lineNoCov">          0 :       base = ci-&gt;u.l.base;</span>
<span class="lineNum">     137 </span><span class="lineNoCov">          0 :       name = luaF_getlocalname(ci_func(ci)-&gt;p, n, currentpc(ci));</span>
<span class="lineNum">     138 </span>            :     }
<span class="lineNum">     139 </span>            :   }
<span class="lineNum">     140 </span>            :   else
<span class="lineNum">     141 </span><span class="lineCov">          3 :     base = ci-&gt;func + 1;</span>
<span class="lineNum">     142 </span><span class="lineCov">          3 :   if (name == NULL) {  /* no 'standard' name? */</span>
<span class="lineNum">     143 </span><span class="lineCov">          3 :     StkId limit = (ci == L-&gt;ci) ? L-&gt;top : ci-&gt;next-&gt;func;</span>
<span class="lineNum">     144 </span><span class="lineCov">          3 :     if (limit - base &gt;= n &amp;&amp; n &gt; 0)  /* is 'n' inside 'ci' stack? */</span>
<span class="lineNum">     145 </span><span class="lineCov">          2 :       name = &quot;(*temporary)&quot;;  /* generic name for any valid slot */</span>
<span class="lineNum">     146 </span>            :     else
<span class="lineNum">     147 </span><span class="lineCov">          1 :       return NULL;  /* no name */</span>
<span class="lineNum">     148 </span>            :   }
<span class="lineNum">     149 </span><span class="lineCov">          2 :   *pos = base + (n - 1);</span>
<span class="lineNum">     150 </span><span class="lineCov">          2 :   return name;</span>
<span class="lineNum">     151 </span>            : }
<span class="lineNum">     152 </span>            : 
<span class="lineNum">     153 </span>            : 
<span class="lineNum">     154 </span><span class="lineCov">          2 : LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {</span>
<span class="lineNum">     155 </span>            :   const char *name;
<span class="lineNum">     156 </span>            :   lua_lock(L);
<span class="lineNum">     157 </span><span class="lineCov">          2 :   swapextra(L);</span>
<span class="lineNum">     158 </span><span class="lineCov">          2 :   if (ar == NULL) {  /* information about non-active function? */</span>
<span class="lineNum">     159 </span><span class="lineCov">          1 :     if (!isLfunction(L-&gt;top - 1))  /* not a Lua function? */</span>
<span class="lineNum">     160 </span><span class="lineNoCov">          0 :       name = NULL;</span>
<span class="lineNum">     161 </span>            :     else  /* consider live variables at function start (parameters) */
<span class="lineNum">     162 </span><span class="lineCov">          1 :       name = luaF_getlocalname(clLvalue(L-&gt;top - 1)-&gt;p, n, 0);</span>
<span class="lineNum">     163 </span>            :   }
<span class="lineNum">     164 </span>            :   else {  /* active function; get information through 'ar' */
<span class="lineNum">     165 </span><span class="lineCov">          1 :     StkId pos = 0;  /* to avoid warnings */</span>
<span class="lineNum">     166 </span><span class="lineCov">          1 :     name = findlocal(L, ar-&gt;i_ci, n, &amp;pos);</span>
<span class="lineNum">     167 </span><span class="lineCov">          1 :     if (name) {</span>
<span class="lineNum">     168 </span><span class="lineCov">          1 :       setobj2s(L, L-&gt;top, pos);</span>
<span class="lineNum">     169 </span><span class="lineCov">          1 :       api_incr_top(L);</span>
<span class="lineNum">     170 </span>            :     }
<span class="lineNum">     171 </span>            :   }
<span class="lineNum">     172 </span><span class="lineCov">          2 :   swapextra(L);</span>
<span class="lineNum">     173 </span>            :   lua_unlock(L);
<span class="lineNum">     174 </span><span class="lineCov">          2 :   return name;</span>
<span class="lineNum">     175 </span>            : }
<span class="lineNum">     176 </span>            : 
<span class="lineNum">     177 </span>            : 
<span class="lineNum">     178 </span><span class="lineCov">          2 : LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {</span>
<span class="lineNum">     179 </span><span class="lineCov">          2 :   StkId pos = 0;  /* to avoid warnings */</span>
<span class="lineNum">     180 </span>            :   const char *name;
<span class="lineNum">     181 </span>            :   lua_lock(L);
<span class="lineNum">     182 </span><span class="lineCov">          2 :   swapextra(L);</span>
<span class="lineNum">     183 </span><span class="lineCov">          2 :   name = findlocal(L, ar-&gt;i_ci, n, &amp;pos);</span>
<span class="lineNum">     184 </span><span class="lineCov">          2 :   if (name)</span>
<span class="lineNum">     185 </span><span class="lineCov">          1 :     setobjs2s(L, pos, L-&gt;top - 1);</span>
<span class="lineNum">     186 </span><span class="lineCov">          2 :   L-&gt;top--;  /* pop value */</span>
<span class="lineNum">     187 </span><span class="lineCov">          2 :   swapextra(L);</span>
<span class="lineNum">     188 </span>            :   lua_unlock(L);
<span class="lineNum">     189 </span><span class="lineCov">          2 :   return name;</span>
<span class="lineNum">     190 </span>            : }
<span class="lineNum">     191 </span>            : 
<span class="lineNum">     192 </span>            : 
<span class="lineNum">     193 </span><span class="lineCov">        165 : static void funcinfo (lua_Debug *ar, Closure *cl) {</span>
<span class="lineNum">     194 </span><span class="lineCov">        165 :   if (noLuaClosure(cl)) {</span>
<span class="lineNum">     195 </span><span class="lineCov">         63 :     ar-&gt;source = &quot;=[C]&quot;;</span>
<span class="lineNum">     196 </span><span class="lineCov">         63 :     ar-&gt;linedefined = -1;</span>
<span class="lineNum">     197 </span><span class="lineCov">         63 :     ar-&gt;lastlinedefined = -1;</span>
<span class="lineNum">     198 </span><span class="lineCov">         63 :     ar-&gt;what = &quot;C&quot;;</span>
<span class="lineNum">     199 </span>            :   }
<span class="lineNum">     200 </span>            :   else {
<span class="lineNum">     201 </span><span class="lineCov">        102 :     Proto *p = cl-&gt;l.p;</span>
<span class="lineNum">     202 </span><span class="lineCov">        102 :     ar-&gt;source = p-&gt;source ? getstr(p-&gt;source) : &quot;=?&quot;;</span>
<span class="lineNum">     203 </span><span class="lineCov">        102 :     ar-&gt;linedefined = p-&gt;linedefined;</span>
<span class="lineNum">     204 </span><span class="lineCov">        102 :     ar-&gt;lastlinedefined = p-&gt;lastlinedefined;</span>
<span class="lineNum">     205 </span><span class="lineCov">        102 :     ar-&gt;what = (ar-&gt;linedefined == 0) ? &quot;main&quot; : &quot;Lua&quot;;</span>
<span class="lineNum">     206 </span>            :   }
<span class="lineNum">     207 </span><span class="lineCov">        165 :   luaO_chunkid(ar-&gt;short_src, ar-&gt;source, LUA_IDSIZE);</span>
<span class="lineNum">     208 </span><span class="lineCov">        165 : }</span>
<span class="lineNum">     209 </span>            : 
<span class="lineNum">     210 </span>            : 
<span class="lineNum">     211 </span><span class="lineCov">          1 : static void collectvalidlines (lua_State *L, Closure *f) {</span>
<span class="lineNum">     212 </span><span class="lineCov">          1 :   if (noLuaClosure(f)) {</span>
<span class="lineNum">     213 </span><span class="lineNoCov">          0 :     setnilvalue(L-&gt;top);</span>
<span class="lineNum">     214 </span><span class="lineNoCov">          0 :     api_incr_top(L);</span>
<span class="lineNum">     215 </span>            :   }
<span class="lineNum">     216 </span>            :   else {
<span class="lineNum">     217 </span>            :     int i;
<span class="lineNum">     218 </span>            :     TValue v;
<span class="lineNum">     219 </span><span class="lineCov">          1 :     int *lineinfo = f-&gt;l.p-&gt;lineinfo;</span>
<span class="lineNum">     220 </span><span class="lineCov">          1 :     Table *t = luaH_new(L);  /* new table to store active lines */</span>
<span class="lineNum">     221 </span><span class="lineCov">          1 :     sethvalue(L, L-&gt;top, t);  /* push it on stack */</span>
<span class="lineNum">     222 </span><span class="lineCov">          1 :     api_incr_top(L);</span>
<span class="lineNum">     223 </span><span class="lineCov">          1 :     setbvalue(&amp;v, 1);  /* boolean 'true' to be the value of all indices */</span>
<span class="lineNum">     224 </span><span class="lineCov">         26 :     for (i = 0; i &lt; f-&gt;l.p-&gt;sizelineinfo; i++)  /* for all lines with code */</span>
<span class="lineNum">     225 </span><span class="lineCov">         25 :       luaH_setint(L, t, lineinfo[i], &amp;v);  /* table[line] = true */</span>
<span class="lineNum">     226 </span>            :   }
<span class="lineNum">     227 </span><span class="lineCov">          1 : }</span>
<span class="lineNum">     228 </span>            : 
<span class="lineNum">     229 </span>            : 
<span class="lineNum">     230 </span><span class="lineCov">        227 : static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,</span>
<span class="lineNum">     231 </span>            :                        Closure *f, CallInfo *ci) {
<span class="lineNum">     232 </span><span class="lineCov">        227 :   int status = 1;</span>
<span class="lineNum">     233 </span><span class="lineCov">        655 :   for (; *what; what++) {</span>
<span class="lineNum">     234 </span><span class="lineCov">        428 :     switch (*what) {</span>
<span class="lineNum">     235 </span><span class="lineCov">        165 :       case 'S': {</span>
<span class="lineNum">     236 </span><span class="lineCov">        165 :         funcinfo(ar, f);</span>
<span class="lineNum">     237 </span><span class="lineCov">        165 :         break;</span>
<span class="lineNum">     238 </span>            :       }
<span class="lineNum">     239 </span><span class="lineCov">        165 :       case 'l': {</span>
<span class="lineNum">     240 </span><span class="lineCov">        165 :         ar-&gt;currentline = (ci &amp;&amp; isLua(ci)) ? currentline(ci) : -1;</span>
<span class="lineNum">     241 </span><span class="lineCov">        165 :         break;</span>
<span class="lineNum">     242 </span>            :       }
<span class="lineNum">     243 </span><span class="lineCov">          6 :       case 'u': {</span>
<span class="lineNum">     244 </span><span class="lineCov">          6 :         ar-&gt;nups = (f == NULL) ? 0 : f-&gt;c.nupvalues;</span>
<span class="lineNum">     245 </span><span class="lineCov">          6 :         if (noLuaClosure(f)) {</span>
<span class="lineNum">     246 </span><span class="lineNoCov">          0 :           ar-&gt;isvararg = 1;</span>
<span class="lineNum">     247 </span><span class="lineNoCov">          0 :           ar-&gt;nparams = 0;</span>
<span class="lineNum">     248 </span>            :         }
<span class="lineNum">     249 </span>            :         else {
<span class="lineNum">     250 </span><span class="lineCov">          6 :           ar-&gt;isvararg = f-&gt;l.p-&gt;is_vararg;</span>
<span class="lineNum">     251 </span><span class="lineCov">          6 :           ar-&gt;nparams = f-&gt;l.p-&gt;numparams;</span>
<span class="lineNum">     252 </span>            :         }
<span class="lineNum">     253 </span><span class="lineCov">          6 :         break;</span>
<span class="lineNum">     254 </span>            :       }
<span class="lineNum">     255 </span><span class="lineCov">         16 :       case 't': {</span>
<span class="lineNum">     256 </span><span class="lineCov">         16 :         ar-&gt;istailcall = (ci) ? ci-&gt;callstatus &amp; CIST_TAIL : 0;</span>
<span class="lineNum">     257 </span><span class="lineCov">         16 :         break;</span>
<span class="lineNum">     258 </span>            :       }
<span class="lineNum">     259 </span><span class="lineCov">         62 :       case 'n': {</span>
<span class="lineNum">     260 </span>            :         /* calling function is a known Lua function? */
<span class="lineNum">     261 </span><span class="lineCov">         62 :         if (ci &amp;&amp; !(ci-&gt;callstatus &amp; CIST_TAIL) &amp;&amp; isLua(ci-&gt;previous))</span>
<span class="lineNum">     262 </span><span class="lineCov">         48 :           ar-&gt;namewhat = getfuncname(L, ci-&gt;previous, &amp;ar-&gt;name);</span>
<span class="lineNum">     263 </span>            :         else
<span class="lineNum">     264 </span><span class="lineCov">         14 :           ar-&gt;namewhat = NULL;</span>
<span class="lineNum">     265 </span><span class="lineCov">         62 :         if (ar-&gt;namewhat == NULL) {</span>
<span class="lineNum">     266 </span><span class="lineCov">         14 :           ar-&gt;namewhat = &quot;&quot;;  /* not found */</span>
<span class="lineNum">     267 </span><span class="lineCov">         14 :           ar-&gt;name = NULL;</span>
<span class="lineNum">     268 </span>            :         }
<span class="lineNum">     269 </span><span class="lineCov">         62 :         break;</span>
<span class="lineNum">     270 </span>            :       }
<span class="lineNum">     271 </span><span class="lineCov">         13 :       case 'L':</span>
<span class="lineNum">     272 </span>            :       case 'f':  /* handled by lua_getinfo */
<span class="lineNum">     273 </span><span class="lineCov">         13 :         break;</span>
<span class="lineNum">     274 </span><span class="lineCov">          1 :       default: status = 0;  /* invalid option */</span>
<span class="lineNum">     275 </span>            :     }
<span class="lineNum">     276 </span>            :   }
<span class="lineNum">     277 </span><span class="lineCov">        227 :   return status;</span>
<span class="lineNum">     278 </span>            : }
<span class="lineNum">     279 </span>            : 
<span class="lineNum">     280 </span>            : 
<span class="lineNum">     281 </span><span class="lineCov">        227 : LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {</span>
<span class="lineNum">     282 </span>            :   int status;
<span class="lineNum">     283 </span>            :   Closure *cl;
<span class="lineNum">     284 </span>            :   CallInfo *ci;
<span class="lineNum">     285 </span>            :   StkId func;
<span class="lineNum">     286 </span>            :   lua_lock(L);
<span class="lineNum">     287 </span><span class="lineCov">        227 :   swapextra(L);</span>
<span class="lineNum">     288 </span><span class="lineCov">        227 :   if (*what == '&gt;') {</span>
<span class="lineNum">     289 </span><span class="lineCov">          7 :     ci = NULL;</span>
<span class="lineNum">     290 </span><span class="lineCov">          7 :     func = L-&gt;top - 1;</span>
<span class="lineNum">     291 </span>            :     api_check(L, ttisfunction(func), &quot;function expected&quot;);
<span class="lineNum">     292 </span><span class="lineCov">          7 :     what++;  /* skip the '&gt;' */</span>
<span class="lineNum">     293 </span><span class="lineCov">          7 :     L-&gt;top--;  /* pop function */</span>
<span class="lineNum">     294 </span>            :   }
<span class="lineNum">     295 </span>            :   else {
<span class="lineNum">     296 </span><span class="lineCov">        220 :     ci = ar-&gt;i_ci;</span>
<span class="lineNum">     297 </span><span class="lineCov">        220 :     func = ci-&gt;func;</span>
<span class="lineNum">     298 </span>            :     lua_assert(ttisfunction(ci-&gt;func));
<span class="lineNum">     299 </span>            :   }
<span class="lineNum">     300 </span><span class="lineCov">        227 :   cl = ttisclosure(func) ? clvalue(func) : NULL;</span>
<span class="lineNum">     301 </span><span class="lineCov">        227 :   status = auxgetinfo(L, what, ar, cl, ci);</span>
<span class="lineNum">     302 </span><span class="lineCov">        227 :   if (strchr(what, 'f')) {</span>
<span class="lineNum">     303 </span><span class="lineCov">         12 :     setobjs2s(L, L-&gt;top, func);</span>
<span class="lineNum">     304 </span><span class="lineCov">         12 :     api_incr_top(L);</span>
<span class="lineNum">     305 </span>            :   }
<span class="lineNum">     306 </span><span class="lineCov">        227 :   swapextra(L);</span>
<span class="lineNum">     307 </span><span class="lineCov">        227 :   if (strchr(what, 'L'))</span>
<span class="lineNum">     308 </span><span class="lineCov">          1 :     collectvalidlines(L, cl);</span>
<span class="lineNum">     309 </span>            :   lua_unlock(L);
<span class="lineNum">     310 </span><span class="lineCov">        227 :   return status;</span>
<span class="lineNum">     311 </span>            : }
<span class="lineNum">     312 </span>            : 
<span class="lineNum">     313 </span>            : 
<span class="lineNum">     314 </span>            : /*
<span class="lineNum">     315 </span>            : ** {======================================================
<span class="lineNum">     316 </span>            : ** Symbolic Execution
<span class="lineNum">     317 </span>            : ** =======================================================
<span class="lineNum">     318 </span>            : */
<span class="lineNum">     319 </span>            : 
<span class="lineNum">     320 </span>            : static const char *getobjname (Proto *p, int lastpc, int reg,
<span class="lineNum">     321 </span>            :                                const char **name);
<span class="lineNum">     322 </span>            : 
<span class="lineNum">     323 </span>            : 
<span class="lineNum">     324 </span>            : /*
<span class="lineNum">     325 </span>            : ** find a &quot;name&quot; for the RK value 'c'
<span class="lineNum">     326 </span>            : */
<span class="lineNum">     327 </span><span class="lineCov">         48 : static void kname (Proto *p, int pc, int c, const char **name) {</span>
<span class="lineNum">     328 </span><span class="lineCov">         48 :   if (ISK(c)) {  /* is 'c' a constant? */</span>
<span class="lineNum">     329 </span><span class="lineCov">         48 :     TValue *kvalue = &amp;p-&gt;k[INDEXK(c)];</span>
<span class="lineNum">     330 </span><span class="lineCov">         48 :     if (ttisstring(kvalue)) {  /* literal constant? */</span>
<span class="lineNum">     331 </span><span class="lineCov">         48 :       *name = svalue(kvalue);  /* it is its own name */</span>
<span class="lineNum">     332 </span><span class="lineCov">         48 :       return;</span>
<span class="lineNum">     333 </span>            :     }
<span class="lineNum">     334 </span>            :     /* else no reasonable name found */
<span class="lineNum">     335 </span>            :   }
<span class="lineNum">     336 </span>            :   else {  /* 'c' is a register */
<span class="lineNum">     337 </span><span class="lineNoCov">          0 :     const char *what = getobjname(p, pc, c, name); /* search for 'c' */</span>
<span class="lineNum">     338 </span><span class="lineNoCov">          0 :     if (what &amp;&amp; *what == 'c') {  /* found a constant name? */</span>
<span class="lineNum">     339 </span><span class="lineNoCov">          0 :       return;  /* 'name' already filled */</span>
<span class="lineNum">     340 </span>            :     }
<span class="lineNum">     341 </span>            :     /* else no reasonable name found */
<span class="lineNum">     342 </span>            :   }
<span class="lineNum">     343 </span><span class="lineNoCov">          0 :   *name = &quot;?&quot;;  /* no reasonable name found */</span>
<span class="lineNum">     344 </span>            : }
<span class="lineNum">     345 </span>            : 
<span class="lineNum">     346 </span>            : 
<span class="lineNum">     347 </span><span class="lineCov">        395 : static int filterpc (int pc, int jmptarget) {</span>
<span class="lineNum">     348 </span><span class="lineCov">        395 :   if (pc &lt; jmptarget)  /* is code conditional (inside a jump)? */</span>
<span class="lineNum">     349 </span><span class="lineCov">        150 :     return -1;  /* cannot know who sets that register */</span>
<span class="lineNum">     350 </span><span class="lineCov">        245 :   else return pc;  /* current position sets that register */</span>
<span class="lineNum">     351 </span>            : }
<span class="lineNum">     352 </span>            : 
<span class="lineNum">     353 </span>            : 
<span class="lineNum">     354 </span>            : /*
<span class="lineNum">     355 </span>            : ** try to find last instruction before 'lastpc' that modified register 'reg'
<span class="lineNum">     356 </span>            : */
<span class="lineNum">     357 </span><span class="lineCov">        106 : static int findsetreg (Proto *p, int lastpc, int reg) {</span>
<span class="lineNum">     358 </span>            :   int pc;
<span class="lineNum">     359 </span><span class="lineCov">        106 :   int setreg = -1;  /* keep last instruction that changed 'reg' */</span>
<span class="lineNum">     360 </span><span class="lineCov">        106 :   int jmptarget = 0;  /* any code before this address is conditional */</span>
<span class="lineNum">     361 </span><span class="lineCov">       1237 :   for (pc = 0; pc &lt; lastpc; pc++) {</span>
<span class="lineNum">     362 </span><span class="lineCov">       1131 :     Instruction i = p-&gt;code[pc];</span>
<span class="lineNum">     363 </span><span class="lineCov">       1131 :     OpCode op = GET_OPCODE(i);</span>
<span class="lineNum">     364 </span><span class="lineCov">       1131 :     int a = GETARG_A(i);</span>
<span class="lineNum">     365 </span><span class="lineCov">       1131 :     switch (op) {</span>
<span class="lineNum">     366 </span><span class="lineCov">         13 :       case OP_LOADNIL: {</span>
<span class="lineNum">     367 </span><span class="lineCov">         13 :         int b = GETARG_B(i);</span>
<span class="lineNum">     368 </span><span class="lineCov">         13 :         if (a &lt;= reg &amp;&amp; reg &lt;= a + b)  /* set registers from 'a' to 'a+b' */</span>
<span class="lineNum">     369 </span><span class="lineCov">          4 :           setreg = filterpc(pc, jmptarget);</span>
<span class="lineNum">     370 </span><span class="lineCov">         13 :         break;</span>
<span class="lineNum">     371 </span>            :       }
<span class="lineNum">     372 </span><span class="lineNoCov">          0 :       case OP_TFORCALL: {</span>
<span class="lineNum">     373 </span><span class="lineNoCov">          0 :         if (reg &gt;= a + 2)  /* affect all regs above its base */</span>
<span class="lineNum">     374 </span><span class="lineNoCov">          0 :           setreg = filterpc(pc, jmptarget);</span>
<span class="lineNum">     375 </span><span class="lineNoCov">          0 :         break;</span>
<span class="lineNum">     376 </span>            :       }
<span class="lineNum">     377 </span><span class="lineCov">        205 :       case OP_CALL:</span>
<span class="lineNum">     378 </span>            :       case OP_TAILCALL: {
<span class="lineNum">     379 </span><span class="lineCov">        205 :         if (reg &gt;= a)  /* affect all registers above base */</span>
<span class="lineNum">     380 </span><span class="lineCov">        204 :           setreg = filterpc(pc, jmptarget);</span>
<span class="lineNum">     381 </span><span class="lineCov">        205 :         break;</span>
<span class="lineNum">     382 </span>            :       }
<span class="lineNum">     383 </span><span class="lineCov">         45 :       case OP_JMP: {</span>
<span class="lineNum">     384 </span><span class="lineCov">         45 :         int b = GETARG_sBx(i);</span>
<span class="lineNum">     385 </span><span class="lineCov">         45 :         int dest = pc + 1 + b;</span>
<span class="lineNum">     386 </span>            :         /* jump is forward and do not skip `lastpc'? */
<span class="lineNum">     387 </span><span class="lineCov">         45 :         if (pc &lt; dest &amp;&amp; dest &lt;= lastpc) {</span>
<span class="lineNum">     388 </span><span class="lineCov">         45 :           if (dest &gt; jmptarget)</span>
<span class="lineNum">     389 </span><span class="lineCov">         36 :             jmptarget = dest;  /* update 'jmptarget' */</span>
<span class="lineNum">     390 </span>            :         }
<span class="lineNum">     391 </span><span class="lineCov">         45 :         break;</span>
<span class="lineNum">     392 </span>            :       }
<span class="lineNum">     393 </span><span class="lineCov">         11 :       case OP_TEST: {</span>
<span class="lineNum">     394 </span><span class="lineCov">         11 :         if (reg == a)  /* jumped code can change 'a' */</span>
<span class="lineNum">     395 </span><span class="lineCov">          1 :           setreg = filterpc(pc, jmptarget);</span>
<span class="lineNum">     396 </span><span class="lineCov">         11 :         break;</span>
<span class="lineNum">     397 </span>            :       }
<span class="lineNum">     398 </span><span class="lineCov">        857 :       default:</span>
<span class="lineNum">     399 </span><span class="lineCov">        857 :         if (testAMode(op) &amp;&amp; reg == a)  /* any instruction that set A */</span>
<span class="lineNum">     400 </span><span class="lineCov">        186 :           setreg = filterpc(pc, jmptarget);</span>
<span class="lineNum">     401 </span><span class="lineCov">        857 :         break;</span>
<span class="lineNum">     402 </span>            :     }
<span class="lineNum">     403 </span>            :   }
<span class="lineNum">     404 </span><span class="lineCov">        106 :   return setreg;</span>
<span class="lineNum">     405 </span>            : }
<span class="lineNum">     406 </span>            : 
<span class="lineNum">     407 </span>            : 
<span class="lineNum">     408 </span><span class="lineCov">        116 : static const char *getobjname (Proto *p, int lastpc, int reg,</span>
<span class="lineNum">     409 </span>            :                                const char **name) {
<span class="lineNum">     410 </span>            :   int pc;
<span class="lineNum">     411 </span><span class="lineCov">        116 :   *name = luaF_getlocalname(p, reg + 1, lastpc);</span>
<span class="lineNum">     412 </span><span class="lineCov">        116 :   if (*name)  /* is a local? */</span>
<span class="lineNum">     413 </span><span class="lineCov">         10 :     return &quot;local&quot;;</span>
<span class="lineNum">     414 </span>            :   /* else try symbolic execution */
<span class="lineNum">     415 </span><span class="lineCov">        106 :   pc = findsetreg(p, lastpc, reg);</span>
<span class="lineNum">     416 </span><span class="lineCov">        106 :   if (pc != -1) {  /* could find instruction? */</span>
<span class="lineNum">     417 </span><span class="lineCov">        106 :     Instruction i = p-&gt;code[pc];</span>
<span class="lineNum">     418 </span><span class="lineCov">        106 :     OpCode op = GET_OPCODE(i);</span>
<span class="lineNum">     419 </span><span class="lineCov">        106 :     switch (op) {</span>
<span class="lineNum">     420 </span><span class="lineNoCov">          0 :       case OP_MOVE: {</span>
<span class="lineNum">     421 </span><span class="lineNoCov">          0 :         int b = GETARG_B(i);  /* move from 'b' to 'a' */</span>
<span class="lineNum">     422 </span><span class="lineNoCov">          0 :         if (b &lt; GETARG_A(i))</span>
<span class="lineNum">     423 </span><span class="lineNoCov">          0 :           return getobjname(p, pc, b, name);  /* get name for 'b' */</span>
<span class="lineNum">     424 </span><span class="lineNoCov">          0 :         break;</span>
<span class="lineNum">     425 </span>            :       }
<span class="lineNum">     426 </span><span class="lineCov">         46 :       case OP_GETTABUP:</span>
<span class="lineNum">     427 </span>            :       case OP_GETTABLE: {
<span class="lineNum">     428 </span><span class="lineCov">         46 :         int k = GETARG_C(i);  /* key index */</span>
<span class="lineNum">     429 </span><span class="lineCov">         46 :         int t = GETARG_B(i);  /* table index */</span>
<span class="lineNum">     430 </span><span class="lineCov">         46 :         const char *vn = (op == OP_GETTABLE)  /* name of indexed variable */</span>
<span class="lineNum">     431 </span><span class="lineCov">         25 :                          ? luaF_getlocalname(p, t + 1, pc)</span>
<span class="lineNum">     432 </span><span class="lineCov">         46 :                          : upvalname(p, t);</span>
<span class="lineNum">     433 </span><span class="lineCov">         46 :         kname(p, pc, k, name);</span>
<span class="lineNum">     434 </span><span class="lineCov">         46 :         return (vn &amp;&amp; strcmp(vn, LUA_ENV) == 0) ? &quot;global&quot; : &quot;field&quot;;</span>
<span class="lineNum">     435 </span>            :       }
<span class="lineNum">     436 </span><span class="lineCov">         37 :       case OP_GETUPVAL: {</span>
<span class="lineNum">     437 </span><span class="lineCov">         37 :         *name = upvalname(p, GETARG_B(i));</span>
<span class="lineNum">     438 </span><span class="lineCov">         37 :         return &quot;upvalue&quot;;</span>
<span class="lineNum">     439 </span>            :       }
<span class="lineNum">     440 </span><span class="lineCov">          1 :       case OP_LOADK:</span>
<span class="lineNum">     441 </span>            :       case OP_LOADKX: {
<span class="lineNum">     442 </span><span class="lineCov">          2 :         int b = (op == OP_LOADK) ? GETARG_Bx(i)</span>
<span class="lineNum">     443 </span><span class="lineCov">          1 :                                  : GETARG_Ax(p-&gt;code[pc + 1]);</span>
<span class="lineNum">     444 </span><span class="lineCov">          1 :         if (ttisstring(&amp;p-&gt;k[b])) {</span>
<span class="lineNum">     445 </span><span class="lineCov">          1 :           *name = svalue(&amp;p-&gt;k[b]);</span>
<span class="lineNum">     446 </span><span class="lineCov">          1 :           return &quot;constant&quot;;</span>
<span class="lineNum">     447 </span>            :         }
<span class="lineNum">     448 </span><span class="lineNoCov">          0 :         break;</span>
<span class="lineNum">     449 </span>            :       }
<span class="lineNum">     450 </span><span class="lineCov">          2 :       case OP_SELF: {</span>
<span class="lineNum">     451 </span><span class="lineCov">          2 :         int k = GETARG_C(i);  /* key index */</span>
<span class="lineNum">     452 </span><span class="lineCov">          2 :         kname(p, pc, k, name);</span>
<span class="lineNum">     453 </span><span class="lineCov">          2 :         return &quot;method&quot;;</span>
<span class="lineNum">     454 </span>            :       }
<span class="lineNum">     455 </span><span class="lineCov">         20 :       default: break;  /* go through to return NULL */</span>
<span class="lineNum">     456 </span>            :     }
<span class="lineNum">     457 </span><span class="lineNoCov">          0 :   }</span>
<span class="lineNum">     458 </span><span class="lineCov">         20 :   return NULL;  /* could not find reasonable name */</span>
<span class="lineNum">     459 </span>            : }
<span class="lineNum">     460 </span>            : 
<span class="lineNum">     461 </span>            : 
<span class="lineNum">     462 </span><span class="lineCov">         48 : static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {</span>
<span class="lineNum">     463 </span>            :   TMS tm;
<span class="lineNum">     464 </span><span class="lineCov">         48 :   Proto *p = ci_func(ci)-&gt;p;  /* calling function */</span>
<span class="lineNum">     465 </span><span class="lineCov">         48 :   int pc = currentpc(ci);  /* calling instruction index */</span>
<span class="lineNum">     466 </span><span class="lineCov">         48 :   Instruction i = p-&gt;code[pc];  /* calling instruction */</span>
<span class="lineNum">     467 </span><span class="lineCov">         48 :   switch (GET_OPCODE(i)) {</span>
<span class="lineNum">     468 </span><span class="lineCov">         48 :     case OP_CALL:</span>
<span class="lineNum">     469 </span>            :     case OP_TAILCALL:  /* get function name */
<span class="lineNum">     470 </span><span class="lineCov">         48 :       return getobjname(p, pc, GETARG_A(i), name);</span>
<span class="lineNum">     471 </span><span class="lineNoCov">          0 :     case OP_TFORCALL: {  /* for iterator */</span>
<span class="lineNum">     472 </span><span class="lineNoCov">          0 :       *name = &quot;for iterator&quot;;</span>
<span class="lineNum">     473 </span><span class="lineNoCov">          0 :        return &quot;for iterator&quot;;</span>
<span class="lineNum">     474 </span>            :     }
<span class="lineNum">     475 </span>            :     /* all other instructions can call only through metamethods */
<span class="lineNum">     476 </span><span class="lineNoCov">          0 :     case OP_SELF:</span>
<span class="lineNum">     477 </span>            :     case OP_GETTABUP:
<span class="lineNum">     478 </span><span class="lineNoCov">          0 :     case OP_GETTABLE: tm = TM_INDEX; break;</span>
<span class="lineNum">     479 </span><span class="lineNoCov">          0 :     case OP_SETTABUP:</span>
<span class="lineNum">     480 </span><span class="lineNoCov">          0 :     case OP_SETTABLE: tm = TM_NEWINDEX; break;</span>
<span class="lineNum">     481 </span><span class="lineNoCov">          0 :     case OP_EQ: tm = TM_EQ; break;</span>
<span class="lineNum">     482 </span><span class="lineNoCov">          0 :     case OP_ADD: tm = TM_ADD; break;</span>
<span class="lineNum">     483 </span><span class="lineNoCov">          0 :     case OP_SUB: tm = TM_SUB; break;</span>
<span class="lineNum">     484 </span><span class="lineNoCov">          0 :     case OP_MUL: tm = TM_MUL; break;</span>
<span class="lineNum">     485 </span><span class="lineNoCov">          0 :     case OP_DIV: tm = TM_DIV; break;</span>
<span class="lineNum">     486 </span><span class="lineNoCov">          0 :     case OP_MOD: tm = TM_MOD; break;</span>
<span class="lineNum">     487 </span><span class="lineNoCov">          0 :     case OP_POW: tm = TM_POW; break;</span>
<span class="lineNum">     488 </span><span class="lineNoCov">          0 :     case OP_UNM: tm = TM_UNM; break;</span>
<span class="lineNum">     489 </span><span class="lineNoCov">          0 :     case OP_LEN: tm = TM_LEN; break;</span>
<span class="lineNum">     490 </span><span class="lineNoCov">          0 :     case OP_LT: tm = TM_LT; break;</span>
<span class="lineNum">     491 </span><span class="lineNoCov">          0 :     case OP_LE: tm = TM_LE; break;</span>
<span class="lineNum">     492 </span><span class="lineNoCov">          0 :     case OP_CONCAT: tm = TM_CONCAT; break;</span>
<span class="lineNum">     493 </span><span class="lineNoCov">          0 :     default:</span>
<span class="lineNum">     494 </span><span class="lineNoCov">          0 :       return NULL;  /* else no useful name can be found */</span>
<span class="lineNum">     495 </span>            :   }
<span class="lineNum">     496 </span><span class="lineNoCov">          0 :   *name = getstr(G(L)-&gt;tmname[tm]);</span>
<span class="lineNum">     497 </span><span class="lineNoCov">          0 :   return &quot;metamethod&quot;;</span>
<span class="lineNum">     498 </span>            : }
<span class="lineNum">     499 </span>            : 
<span class="lineNum">     500 </span>            : /* }====================================================== */
<span class="lineNum">     501 </span>            : 
<span class="lineNum">     502 </span>            : 
<span class="lineNum">     503 </span>            : 
<span class="lineNum">     504 </span>            : /*
<span class="lineNum">     505 </span>            : ** only ANSI way to check whether a pointer points to an array
<span class="lineNum">     506 </span>            : ** (used only for error messages, so efficiency is not a big concern)
<span class="lineNum">     507 </span>            : */
<span class="lineNum">     508 </span><span class="lineCov">        104 : static int isinstack (CallInfo *ci, const TValue *o) {</span>
<span class="lineNum">     509 </span>            :   StkId p;
<span class="lineNum">     510 </span><span class="lineCov">        178 :   for (p = ci-&gt;u.l.base; p &lt; ci-&gt;top; p++)</span>
<span class="lineNum">     511 </span><span class="lineCov">        142 :     if (o == p) return 1;</span>
<span class="lineNum">     512 </span><span class="lineCov">         36 :   return 0;</span>
<span class="lineNum">     513 </span>            : }
<span class="lineNum">     514 </span>            : 
<span class="lineNum">     515 </span>            : 
<span class="lineNum">     516 </span><span class="lineCov">        108 : static const char *getupvalname (CallInfo *ci, const TValue *o,</span>
<span class="lineNum">     517 </span>            :                                  const char **name) {
<span class="lineNum">     518 </span><span class="lineCov">        108 :   LClosure *c = ci_func(ci);</span>
<span class="lineNum">     519 </span>            :   int i;
<span class="lineNum">     520 </span><span class="lineCov">        158 :   for (i = 0; i &lt; c-&gt;nupvalues; i++) {</span>
<span class="lineNum">     521 </span><span class="lineCov">         54 :     if (c-&gt;upvals[i]-&gt;v == o) {</span>
<span class="lineNum">     522 </span><span class="lineCov">          4 :       *name = upvalname(c-&gt;p, i);</span>
<span class="lineNum">     523 </span><span class="lineCov">          4 :       return &quot;upvalue&quot;;</span>
<span class="lineNum">     524 </span>            :     }
<span class="lineNum">     525 </span>            :   }
<span class="lineNum">     526 </span><span class="lineCov">        104 :   return NULL;</span>
<span class="lineNum">     527 </span>            : }
<span class="lineNum">     528 </span>            : 
<span class="lineNum">     529 </span>            : 
<span class="lineNum">     530 </span><span class="lineCov">        110 : l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) {</span>
<span class="lineNum">     531 </span><span class="lineCov">        110 :   CallInfo *ci = L-&gt;ci;</span>
<span class="lineNum">     532 </span><span class="lineCov">        110 :   const char *name = NULL;</span>
<span class="lineNum">     533 </span><span class="lineCov">        110 :   const char *t = objtypename(o);</span>
<span class="lineNum">     534 </span><span class="lineCov">        110 :   const char *kind = NULL;</span>
<span class="lineNum">     535 </span><span class="lineCov">        110 :   if (isLua(ci)) {</span>
<span class="lineNum">     536 </span><span class="lineCov">        108 :     kind = getupvalname(ci, o, &amp;name);  /* check whether 'o' is an upvalue */</span>
<span class="lineNum">     537 </span><span class="lineCov">        108 :     if (!kind &amp;&amp; isinstack(ci, o))  /* no? try a register */</span>
<span class="lineNum">     538 </span><span class="lineCov">         68 :       kind = getobjname(ci_func(ci)-&gt;p, currentpc(ci),</span>
<span class="lineNum">     539 </span><span class="lineCov">         68 :                         cast_int(o - ci-&gt;u.l.base), &amp;name);</span>
<span class="lineNum">     540 </span>            :   }
<span class="lineNum">     541 </span><span class="lineCov">        110 :   if (kind)</span>
<span class="lineNum">     542 </span><span class="lineCov">         52 :     luaG_runerror(L, &quot;attempt to %s %s &quot; LUA_QS &quot; (a %s value)&quot;,</span>
<span class="lineNum">     543 </span>            :                 op, kind, name, t);
<span class="lineNum">     544 </span>            :   else
<span class="lineNum">     545 </span><span class="lineCov">         58 :     luaG_runerror(L, &quot;attempt to %s a %s value&quot;, op, t);</span>
<span class="lineNum">     546 </span>            : }
<span class="lineNum">     547 </span>            : 
<span class="lineNum">     548 </span>            : 
<span class="lineNum">     549 </span><span class="lineCov">          9 : l_noret luaG_concaterror (lua_State *L, StkId p1, StkId p2) {</span>
<span class="lineNum">     550 </span><span class="lineCov">          9 :   if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;</span>
<span class="lineNum">     551 </span>            :   lua_assert(!ttisstring(p1) &amp;&amp; !ttisnumber(p1));
<span class="lineNum">     552 </span><span class="lineCov">          9 :   luaG_typeerror(L, p1, &quot;concatenate&quot;);</span>
<span class="lineNum">     553 </span>            : }
<span class="lineNum">     554 </span>            : 
<span class="lineNum">     555 </span>            : 
<span class="lineNum">     556 </span><span class="lineCov">         78 : l_noret luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {</span>
<span class="lineNum">     557 </span>            :   TValue temp;
<span class="lineNum">     558 </span><span class="lineCov">         78 :   if (luaV_tonumber(p1, &amp;temp) == NULL)</span>
<span class="lineNum">     559 </span><span class="lineCov">         51 :     p2 = p1;  /* first operand is wrong */</span>
<span class="lineNum">     560 </span><span class="lineCov">         78 :   luaG_typeerror(L, p2, &quot;perform arithmetic on&quot;);</span>
<span class="lineNum">     561 </span>            : }
<span class="lineNum">     562 </span>            : 
<span class="lineNum">     563 </span>            : 
<span class="lineNum">     564 </span><span class="lineCov">         74 : l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {</span>
<span class="lineNum">     565 </span><span class="lineCov">         74 :   const char *t1 = objtypename(p1);</span>
<span class="lineNum">     566 </span><span class="lineCov">         74 :   const char *t2 = objtypename(p2);</span>
<span class="lineNum">     567 </span><span class="lineCov">         74 :   if (t1 == t2)</span>
<span class="lineNum">     568 </span><span class="lineCov">         28 :     luaG_runerror(L, &quot;attempt to compare two %s values&quot;, t1);</span>
<span class="lineNum">     569 </span>            :   else
<span class="lineNum">     570 </span><span class="lineCov">         46 :     luaG_runerror(L, &quot;attempt to compare %s with %s&quot;, t1, t2);</span>
<span class="lineNum">     571 </span>            : }
<span class="lineNum">     572 </span>            : 
<span class="lineNum">     573 </span>            : 
<span class="lineNum">     574 </span><span class="lineCov">        192 : static void addinfo (lua_State *L, const char *msg) {</span>
<span class="lineNum">     575 </span><span class="lineCov">        192 :   CallInfo *ci = L-&gt;ci;</span>
<span class="lineNum">     576 </span><span class="lineCov">        192 :   if (isLua(ci)) {  /* is Lua code? */</span>
<span class="lineNum">     577 </span>            :     char buff[LUA_IDSIZE];  /* add file:line information */
<span class="lineNum">     578 </span><span class="lineCov">        187 :     int line = currentline(ci);</span>
<span class="lineNum">     579 </span><span class="lineCov">        187 :     TString *src = ci_func(ci)-&gt;p-&gt;source;</span>
<span class="lineNum">     580 </span><span class="lineCov">        187 :     if (src)</span>
<span class="lineNum">     581 </span><span class="lineCov">        187 :       luaO_chunkid(buff, getstr(src), LUA_IDSIZE);</span>
<span class="lineNum">     582 </span>            :     else {  /* no source available; use &quot;?&quot; instead */
<span class="lineNum">     583 </span><span class="lineNoCov">          0 :       buff[0] = '?'; buff[1] = '\0';</span>
<span class="lineNum">     584 </span>            :     }
<span class="lineNum">     585 </span><span class="lineCov">        187 :     luaO_pushfstring(L, &quot;%s:%d: %s&quot;, buff, line, msg);</span>
<span class="lineNum">     586 </span>            :   }
<span class="lineNum">     587 </span><span class="lineCov">        192 : }</span>
<span class="lineNum">     588 </span>            : 
<span class="lineNum">     589 </span>            : 
<span class="lineNum">     590 </span><span class="lineCov">        348 : l_noret luaG_errormsg (lua_State *L) {</span>
<span class="lineNum">     591 </span><span class="lineCov">        348 :   if (L-&gt;errfunc != 0) {  /* is there an error handling function? */</span>
<span class="lineNum">     592 </span><span class="lineCov">         11 :     StkId errfunc = restorestack(L, L-&gt;errfunc);</span>
<span class="lineNum">     593 </span><span class="lineCov">         11 :     if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR);</span>
<span class="lineNum">     594 </span><span class="lineCov">         10 :     setobjs2s(L, L-&gt;top, L-&gt;top - 1);  /* move argument */</span>
<span class="lineNum">     595 </span><span class="lineCov">         10 :     setobjs2s(L, L-&gt;top - 1, errfunc);  /* push function */</span>
<span class="lineNum">     596 </span><span class="lineCov">         10 :     L-&gt;top++;</span>
<span class="lineNum">     597 </span><span class="lineCov">         10 :     luaD_call(L, L-&gt;top - 2, 1, 0);  /* call it */</span>
<span class="lineNum">     598 </span>            :   }
<span class="lineNum">     599 </span><span class="lineCov">        347 :   luaD_throw(L, LUA_ERRRUN);</span>
<span class="lineNum">     600 </span>            : }
<span class="lineNum">     601 </span>            : 
<span class="lineNum">     602 </span>            : 
<span class="lineNum">     603 </span><span class="lineCov">        192 : l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {</span>
<span class="lineNum">     604 </span>            :   va_list argp;
<span class="lineNum">     605 </span><span class="lineCov">        192 :   va_start(argp, fmt);</span>
<span class="lineNum">     606 </span><span class="lineCov">        192 :   addinfo(L, luaO_pushvfstring(L, fmt, argp));</span>
<span class="lineNum">     607 </span><span class="lineCov">        192 :   va_end(argp);</span>
<span class="lineNum">     608 </span><span class="lineCov">        192 :   luaG_errormsg(L);</span>
<span class="lineNum">     609 </span>            : }
<span class="lineNum">     610 </span>            : 
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.13</a></td></tr>
  </table>
  <br>

</body>
</html>
